﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.AutomaticPathPlanner.CApAPPLimitsUserControl
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.AutomaticPathPlanner;

public class CApAPPLimitsUserControl : UserControl, IComponentConnector
{
  private CApAPPObjectFlowTask m_currentLimitsObjectFlowTask;
  private List<CApAPPLimitsViewModel> m_limitViewModelPerTaskList;
  private bool m_isParentWindowActivated;
  internal Grid limitsGroupContainer;
  internal RowDefinition groupLimitsRow;
  internal ColumnDefinition groupLimitsColumn;
  internal GroupBox groupBoxLimits;
  internal Grid operationsContainer;
  internal RowDefinition operationsRow;
  internal ColumnDefinition opLabelColumn;
  internal ColumnDefinition opComboColumn;
  internal ColumnDefinition op2ndComboColumn;
  internal ColumnDefinition opTooltipColumn;
  internal TextBlock tbOperationNames;
  internal ComboBox cbOperationNames;
  internal Grid limitsStackPanelContainer;
  internal RowDefinition panelLimitsRow;
  internal ColumnDefinition translationLimitsColumn;
  internal ColumnDefinition rotationLimitsColumn;
  internal StackPanel stackPanelTranslation;
  internal Grid createTranslationLimits;
  internal Image iconTranslationLock;
  internal TextBlock labelTranslationMinValue;
  internal TextBlock labelTranslationMaxValue;
  internal TextBlock labelTranslationMinValueHidden;
  internal TextBlock labelTranslationMaxValueHidden;
  internal CheckBox cbLimitsTx;
  internal CheckBox cbLockedTx;
  internal TxNumericEditBoxControl TxNumericEditTxMin;
  internal TxNumericEditBoxControl TxNumericEditTxMax;
  internal CheckBox cbLimitsTy;
  internal CheckBox cbLockedTy;
  internal TxNumericEditBoxControl TxNumericEditTyMin;
  internal TxNumericEditBoxControl TxNumericEditTyMax;
  internal CheckBox cbLimitsTz;
  internal CheckBox cbLockedTz;
  internal TxNumericEditBoxControl TxNumericEditTzMin;
  internal TxNumericEditBoxControl TxNumericEditTzMax;
  internal Grid showGraphicLimitsGrid;
  internal CheckBox cbShowInViewer;
  internal StackPanel stackPanelRotation;
  internal Grid createRotationLimits;
  internal Image iconRotationLock;
  internal TextBlock labelRotationMinValue;
  internal TextBlock labelRotationMaxValue;
  internal TextBlock labelRotationMinValueHidden;
  internal TextBlock labelRotationMaxValueHidden;
  internal CheckBox cbLimitsRx;
  internal CheckBox cbLockedRx;
  internal TxNumericEditBoxControl TxNumericEditRxMin;
  internal TxNumericEditBoxControl TxNumericEditRxMax;
  internal CheckBox cbLimitsRy;
  internal CheckBox cbLockedRy;
  internal TxNumericEditBoxControl TxNumericEditRyMin;
  internal TxNumericEditBoxControl TxNumericEditRyMax;
  internal CheckBox cbLimitsRz;
  internal CheckBox cbLockedRz;
  internal TxNumericEditBoxControl TxNumericEditRzMin;
  internal TxNumericEditBoxControl TxNumericEditRzMax;
  internal Grid simulateRotationLimits;
  internal TextBlock labelPreviewSimulate;
  internal Button btPreviewRx;
  internal Button btPreviewRy;
  internal Button btPreviewRz;
  private bool _contentLoaded;

  public CApAPPLimitsUserControl()
  {
    this.RotationLowerMinBound = -1.0 * Math.PI;
    this.RotationLowerMaxBound = 0.0;
    this.RotationUpperMinBound = 0.0;
    this.RotationUpperMaxBound = Math.PI;
    this.TranslationLowerMinBound = -100000.0;
    this.TranslationLowerMaxBound = 0.0;
    this.TranslationUpperMinBound = 0.0;
    this.TranslationUpperMaxBound = 100000.0;
    this.LimitError = new CApAPPLimitError();
    this.UsedLimitsViewModel = new CApAPPLimitsViewModel();
    this.InitializeComponent();
  }

  private void LimitsViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
  {
    this.UpdateLimitError();
  }

  public CApAPPLimitError LimitError { get; set; }

  public CApAPPLimitsViewModel UsedLimitsViewModel { get; set; }

  public bool ShowTranslationLimitsWallsInGraphicViewer
  {
    get
    {
      bool wallsInGraphicViewer = true;
      if (this.TaskGUIParameters != null)
        wallsInGraphicViewer = this.TaskGUIParameters.ShowTranslationLimitsInGraphicViewer;
      return wallsInGraphicViewer;
    }
    set
    {
      if (this.TaskGUIParameters != null)
        this.TaskGUIParameters.ShowTranslationLimitsInGraphicViewer = value;
      this.UpdateTranslationLimitWallsDisplay();
    }
  }

  public double TestValue { get; set; }

  public CApAPPObjectFlowTask CurrentLimitsObjectFlowTask
  {
    get => this.m_currentLimitsObjectFlowTask;
    set
    {
      this.m_currentLimitsObjectFlowTask = value;
      this.TranslationLimitsManager.IsWallDisplayActivated = false;
      this.TranslationLimitsManager.LimitsViewModel = this.UsedLimitsViewModel;
      this.RotationLimitsManager.LimitsViewModel = this.UsedLimitsViewModel;
      this.UsedLimitsViewModel.CopyDataFromModel(this.RetrieveLimitViewModelForTask(this.m_currentLimitsObjectFlowTask));
      this.UpdateTranslationLimitWallsDisplay();
    }
  }

  public KiAppPathPlanningParamsEx PathPlanningParams { get; set; }

  public CApAPPTaskGUIParameters TaskGUIParameters { get; set; }

  public CApAPPRotationLimitsGlobalManager RotationLimitsManager { get; set; }

  public CApAPPTranslationLimitsGlobalManager TranslationLimitsManager { get; set; }

  public CApAPPTaskManager TaskManager { get; set; }

  public new bool IsInitialized
  {
    get => this.RotationLimitsManager != null && this.TranslationLimitsManager != null;
    set
    {
    }
  }

  public double TranslationLowerMinBound { get; set; }

  public double TranslationLowerMaxBound { get; set; }

  public double TranslationUpperMinBound { get; set; }

  public double TranslationUpperMaxBound { get; set; }

  public double RotationLowerMinBound { get; set; }

  public double RotationLowerMaxBound { get; set; }

  public double RotationUpperMinBound { get; set; }

  public double RotationUpperMaxBound { get; set; }

  public void Restore()
  {
    this.TranslationLimitsManager.Restore();
    this.RotationLimitsManager.Restore();
    this.UsedLimitsViewModel.CopyDataFromModel(this.RetrieveLimitViewModelForTask(this.CurrentLimitsObjectFlowTask));
    this.UpdateTranslationLimitWallsDisplay();
  }

  public void OnClose() => this.TranslationLimitsManager.ClearTranslationLimitsWalls();

  private CApAPPLimitsViewModel RetrieveLimitViewModelForTask(CApAPPObjectFlowTask objectFlowTask)
  {
    int index = 0;
    CApAPPLimitsViewModel appLimitsViewModel = (CApAPPLimitsViewModel) null;
    foreach (CApAPPObjectFlowTask task in this.TaskManager.Tasks)
    {
      if (task != objectFlowTask)
        ++index;
      else
        break;
    }
    if (this.m_limitViewModelPerTaskList == null)
      this.InitLimitsViewModel();
    if (this.m_limitViewModelPerTaskList != null && index < this.m_limitViewModelPerTaskList.Count)
      appLimitsViewModel = this.m_limitViewModelPerTaskList[index];
    return appLimitsViewModel;
  }

  private void InitLimitsViewModel()
  {
    this.m_limitViewModelPerTaskList = new List<CApAPPLimitsViewModel>();
    foreach (CApAPPObjectFlowTask task in this.TaskManager.Tasks)
      this.m_limitViewModelPerTaskList.Add(new CApAPPLimitsViewModel()
      {
        Limits = task.Limits,
        ReferenceFrame = task.Waypoint(0).SimulatedApproachLocation.AbsoluteLocation
      });
    this.UsedLimitsViewModel.PropertyChanged += new PropertyChangedEventHandler(this.LimitsViewModel_PropertyChanged);
  }

  public void InitLimits()
  {
    this.RotationLimitsManager = new CApAPPRotationLimitsGlobalManager();
    this.TranslationLimitsManager = new CApAPPTranslationLimitsGlobalManager();
    if (this.TaskManager == null)
      return;
    this.InitRotationLimits();
    this.InitTranslationLimits();
    this.FillOperationNameCombo();
    if (this.CurrentLimitsObjectFlowTask == null && this.TaskManager.Tasks[0] is CApAPPObjectFlowTask)
      this.CurrentLimitsObjectFlowTask = this.TaskManager.Tasks[0] as CApAPPObjectFlowTask;
    this.UpdateTranslationLimitWallsDisplay();
  }

  public void UpdateLimitError()
  {
    string errorMessage1 = "";
    string errorMessage2 = "";
    List<CApAPPWaypoint> wps1 = (List<CApAPPWaypoint>) null;
    List<CApAPPWaypoint> wps2 = (List<CApAPPWaypoint>) null;
    CApAPPObjectFlowTask task = (CApAPPObjectFlowTask) null;
    bool flag1 = this.AreTranslationLimitsValid(out errorMessage2, out wps1, out task);
    bool flag2 = this.AreRotationLimitsValid(out errorMessage1, out wps2);
    this.LimitError.WaypointsWithTranslationError = wps1;
    this.LimitError.WaypointsWithRotationError = wps2;
    if (!flag1)
    {
      this.LimitError.ErrorMessage = errorMessage2;
      this.LimitError.ErrorType = flag2 ? CApAPPLimitError.LimitErrorType.TRANSLATION_LIMITS_ERROR : CApAPPLimitError.LimitErrorType.TRANSLATION_ROTATION_LIMITS_ERROR;
      if (task == null)
        return;
      this.LimitError.InvalidOperationName = task.Name;
    }
    else if (!flag2)
    {
      this.LimitError.ErrorType = CApAPPLimitError.LimitErrorType.ROTATION_LIMITS_ERROR;
      this.LimitError.ErrorMessage = errorMessage1;
    }
    else
    {
      this.LimitError.ErrorType = CApAPPLimitError.LimitErrorType.NO_ERROR;
      this.LimitError.ErrorMessage = "";
    }
  }

  private bool AreTranslationLimitsValid(
    out string errorMessage,
    out List<CApAPPWaypoint> wps,
    out CApAPPObjectFlowTask task)
  {
    wps = (List<CApAPPWaypoint>) null;
    errorMessage = "";
    task = (CApAPPObjectFlowTask) null;
    List<CApAPPWaypoint> wps1 = (List<CApAPPWaypoint>) null;
    string errorMessage1 = "";
    task = this.CurrentLimitsObjectFlowTask;
    bool flag = this.AreTranslationLimitsValid(this.CurrentLimitsObjectFlowTask, out errorMessage, out wps);
    if (!flag)
      task = this.CurrentLimitsObjectFlowTask;
    foreach (CApAPPObjectFlowTask task1 in this.TaskManager.Tasks)
    {
      if (task1 != this.CurrentLimitsObjectFlowTask && !this.AreTranslationLimitsValid(task1, out errorMessage1, out wps1))
      {
        flag = false;
        if (wps.Count != 0)
          wps.InsertRange(wps.Count - 1, (IEnumerable<CApAPPWaypoint>) wps1);
        else
          wps = wps1;
        if (errorMessage == "")
        {
          task = task1;
          errorMessage = errorMessage1;
        }
      }
    }
    return flag;
  }

  private bool AreTranslationLimitsValid(
    CApAPPObjectFlowTask objectFlowTask,
    out string errorMessage,
    out List<CApAPPWaypoint> wps)
  {
    errorMessage = "";
    wps = new List<CApAPPWaypoint>();
    bool flag = this.TranslationLimitsManager.AreTranslationLimitsValidForTaskWithErrorMessage(objectFlowTask, out errorMessage, out wps);
    if (flag)
    {
      foreach (CApAPPObjectFlowTask task in this.TaskManager.Tasks)
      {
        if (task != this.CurrentLimitsObjectFlowTask)
          flag = this.TranslationLimitsManager.AreTranslationLimitsValidForTaskWithErrorMessage(task, out errorMessage, out wps);
      }
    }
    return flag;
  }

  private bool AreRotationLimitsValid(out string errorMessage, out List<CApAPPWaypoint> wps)
  {
    bool flag = true;
    errorMessage = "";
    wps = (List<CApAPPWaypoint>) null;
    if (this.TaskManager.IsObjectFlowMode)
    {
      errorMessage = "";
      flag = this.RotationLimitsManager.AreRotationLimitsValidForTask(this.CurrentLimitsObjectFlowTask, out errorMessage, out wps);
      if (flag)
      {
        foreach (CApAPPObjectFlowTask task in this.TaskManager.Tasks)
        {
          if (task != this.CurrentLimitsObjectFlowTask)
          {
            flag = this.RotationLimitsManager.AreRotationLimitsValidForTask(task, out errorMessage, out wps);
            if (!flag)
              break;
          }
        }
      }
    }
    return flag;
  }

  public void UpdateTranslationLimitWallsDisplay()
  {
    this.TranslationLimitsManager.IsWallDisplayActivated = this.ShowTranslationLimitsWallsInGraphicViewer;
  }

  private void InitRotationLimits()
  {
    List<CApAPPObjectFlowTask> appObjectFlowTaskList = new List<CApAPPObjectFlowTask>();
    foreach (CApAPPTask task in this.TaskManager.Tasks)
    {
      CApAPPObjectFlowTask appObjectFlowTask = task as CApAPPObjectFlowTask;
      appObjectFlowTaskList.Add(appObjectFlowTask);
    }
    this.RotationLimitsManager.ObjectFlowTaskList = appObjectFlowTaskList;
    this.InitRotationRow();
  }

  private void InitTranslationLimits()
  {
    List<CApAPPObjectFlowTask> appObjectFlowTaskList = new List<CApAPPObjectFlowTask>();
    foreach (CApAPPTask task in this.TaskManager.Tasks)
    {
      CApAPPObjectFlowTask appObjectFlowTask = task as CApAPPObjectFlowTask;
      appObjectFlowTaskList.Add(appObjectFlowTask);
    }
    this.TranslationLimitsManager.ObjectFlowTaskList = appObjectFlowTaskList;
    this.InitTranslationRow();
    this.ShowTranslationLimitsWallsInGraphicViewer = this.TaskGUIParameters.ShowTranslationLimitsInGraphicViewer;
  }

  private void InitRotationRow()
  {
    if (this.labelRotationMinValue.Text.IndexOf(TxApplication.Options.Units.AngularUnitName) != -1)
      return;
    this.labelRotationMinValue.Text = $"{this.labelRotationMinValue.Text} ({TxApplication.Options.Units.AngularUnitName})";
    this.labelRotationMaxValue.Text = $"{this.labelRotationMaxValue.Text} ({TxApplication.Options.Units.AngularUnitName})";
  }

  private void InitTranslationRow()
  {
    if (this.labelTranslationMinValue.Text.IndexOf(TxApplication.Options.Units.LinearUnitName) != -1)
      return;
    this.labelTranslationMinValue.Text = $"{this.labelTranslationMinValue.Text} ({TxApplication.Options.Units.LinearUnitName})";
    this.labelTranslationMaxValue.Text = $"{this.labelTranslationMaxValue.Text} ({TxApplication.Options.Units.LinearUnitName})";
  }

  private void RotationAnimation(AxisType axisType)
  {
    Window window = Window.GetWindow((DependencyObject) this);
    if (window == null)
      return;
    window.IsEnabled = false;
    this.RotationLimitsManager.AnimateRotationRange(this.CurrentLimitsObjectFlowTask, axisType);
    window.IsEnabled = true;
  }

  private void FillOperationNameCombo()
  {
    ObservableCollection<string> observableCollection = new ObservableCollection<string>();
    foreach (CApAPPTask task in this.TaskManager.Tasks)
    {
      string name = ((ITxObject) task.Operation).Name;
      observableCollection.Add(name);
    }
    this.cbOperationNames.SetBinding(ItemsControl.ItemsSourceProperty, (BindingBase) new Binding()
    {
      Source = (object) observableCollection
    });
  }

  public void OnParentWindowActivated()
  {
    this.m_isParentWindowActivated = true;
    this.UpdateInitialTranslationLimits();
  }

  public void UpdateInitialTranslationLimits()
  {
    this.TranslationLimitsManager.UpdateInitialTranslationLimits();
  }

  private void ShowOperationNameComboVisibility()
  {
    this.tbOperationNames.Visibility = Visibility.Visible;
    this.cbOperationNames.Visibility = Visibility.Visible;
  }

  private void HideOperationNameComboVisibility()
  {
    this.tbOperationNames.Visibility = Visibility.Collapsed;
    this.cbOperationNames.Visibility = Visibility.Collapsed;
  }

  private void cbOperationNames_DropDownClosed(object sender, EventArgs e)
  {
    int index = (sender as ComboBox).SelectedIndex;
    if (index == -1)
      index = 0;
    this.CurrentLimitsObjectFlowTask = this.TaskManager.Tasks[index] as CApAPPObjectFlowTask;
  }

  private void btPreviewRx_Click(object sender, RoutedEventArgs e)
  {
    this.RotationAnimation(AxisType.AXIS_RX);
  }

  private void btPreviewRy_Click(object sender, RoutedEventArgs e)
  {
    this.RotationAnimation(AxisType.AXIS_RY);
  }

  private void btPreviewRz_Click(object sender, RoutedEventArgs e)
  {
    this.RotationAnimation(AxisType.AXIS_RZ);
  }

  private void OnMinRotationEditorSizeChanged(object sender, SizeChangedEventArgs args)
  {
    if (!(sender is TxNumericEditBoxControl numericEditBoxControl1))
      return;
    TxNumericEditBoxControl numericEditBoxControl2 = numericEditBoxControl1;
    double actualWidth = (double) (int) this.createRotationLimits.ColumnDefinitions[2].ActualWidth;
    Thickness margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double left = margin.Left;
    double num1 = actualWidth - left;
    margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double right = margin.Right;
    double num2 = num1 - right;
    ((FrameworkElement) numericEditBoxControl2).Width = num2;
    ((FrameworkElement) numericEditBoxControl1).MaxWidth = (double) (int) ((FrameworkElement) numericEditBoxControl1).Width;
  }

  private void OnMaxRotationEditorSizeChanged(object sender, SizeChangedEventArgs args)
  {
    if (!(sender is TxNumericEditBoxControl numericEditBoxControl1))
      return;
    TxNumericEditBoxControl numericEditBoxControl2 = numericEditBoxControl1;
    double actualWidth = (double) (int) this.createRotationLimits.ColumnDefinitions[3].ActualWidth;
    Thickness margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double left = margin.Left;
    double num1 = actualWidth - left;
    margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double right = margin.Right;
    double num2 = num1 - right;
    ((FrameworkElement) numericEditBoxControl2).Width = num2;
    ((FrameworkElement) numericEditBoxControl1).MaxWidth = (double) (int) ((FrameworkElement) numericEditBoxControl1).Width;
  }

  private void OnMinTranslationEditorSizeChanged(object sender, SizeChangedEventArgs args)
  {
    if (!(sender is TxNumericEditBoxControl numericEditBoxControl1))
      return;
    TxNumericEditBoxControl numericEditBoxControl2 = numericEditBoxControl1;
    double actualWidth = (double) (int) this.createTranslationLimits.ColumnDefinitions[2].ActualWidth;
    Thickness margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double left = margin.Left;
    double num1 = actualWidth - left;
    margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double right = margin.Right;
    double num2 = num1 - right;
    ((FrameworkElement) numericEditBoxControl2).Width = num2;
    ((FrameworkElement) numericEditBoxControl1).MaxWidth = (double) (int) ((FrameworkElement) numericEditBoxControl1).Width;
  }

  private void OnMaxTranslationEditorSizeChanged(object sender, SizeChangedEventArgs args)
  {
    if (!(sender is TxNumericEditBoxControl numericEditBoxControl1))
      return;
    TxNumericEditBoxControl numericEditBoxControl2 = numericEditBoxControl1;
    double actualWidth = (double) (int) this.createTranslationLimits.ColumnDefinitions[3].ActualWidth;
    Thickness margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double left = margin.Left;
    double num1 = actualWidth - left;
    margin = ((FrameworkElement) numericEditBoxControl1).Margin;
    double right = margin.Right;
    double num2 = num1 - right;
    ((FrameworkElement) numericEditBoxControl2).Width = num2;
    ((FrameworkElement) numericEditBoxControl1).MaxWidth = (double) (int) ((FrameworkElement) numericEditBoxControl1).Width;
  }

  private void TxNumericEditRxMin_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (!this.m_isParentWindowActivated)
      return;
    this.UsedLimitsViewModel.SetRxMinValueIfNotLockedNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    double actualWidth = this.createRotationLimits.ColumnDefinitions[2].ActualWidth;
    this.UpdateLimitError();
  }

  private void TxNumericEditRxMax_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (!this.m_isParentWindowActivated)
      return;
    this.UsedLimitsViewModel.SetRxMaxValueIfNotLockedNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    this.UpdateLimitError();
  }

  private void TxNumericEditRyMin_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (!this.m_isParentWindowActivated)
      return;
    this.UsedLimitsViewModel.SetRyMinValueIfNotLockedNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    double actualWidth = this.createRotationLimits.ColumnDefinitions[2].ActualWidth;
    this.UpdateLimitError();
  }

  private void TxNumericEditRyMax_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (!this.m_isParentWindowActivated)
      return;
    this.UsedLimitsViewModel.SetRyMaxValueIfNotLockedNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    this.UpdateLimitError();
  }

  private void TxNumericEditRzMin_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (!this.m_isParentWindowActivated)
      return;
    this.UsedLimitsViewModel.SetRzMinValueIfNotLockedNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    double actualWidth = this.createRotationLimits.ColumnDefinitions[2].ActualWidth;
    this.UpdateLimitError();
  }

  private void TxNumericEditRzMax_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (!this.m_isParentWindowActivated)
      return;
    this.UsedLimitsViewModel.SetRzMaxValueIfNotLockedNoEventSent(args.TentativeValue * TxApplication.Options.Units.AngularMultiplier);
    this.UpdateLimitError();
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/automaticpathplanner/limits/capapplimitsusercontrol.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this.limitsGroupContainer = (Grid) target;
        break;
      case 2:
        this.groupLimitsRow = (RowDefinition) target;
        break;
      case 3:
        this.groupLimitsColumn = (ColumnDefinition) target;
        break;
      case 4:
        this.groupBoxLimits = (GroupBox) target;
        break;
      case 5:
        this.operationsContainer = (Grid) target;
        break;
      case 6:
        this.operationsRow = (RowDefinition) target;
        break;
      case 7:
        this.opLabelColumn = (ColumnDefinition) target;
        break;
      case 8:
        this.opComboColumn = (ColumnDefinition) target;
        break;
      case 9:
        this.op2ndComboColumn = (ColumnDefinition) target;
        break;
      case 10:
        this.opTooltipColumn = (ColumnDefinition) target;
        break;
      case 11:
        this.tbOperationNames = (TextBlock) target;
        break;
      case 12:
        this.cbOperationNames = (ComboBox) target;
        this.cbOperationNames.DropDownClosed += new EventHandler(this.cbOperationNames_DropDownClosed);
        break;
      case 13:
        this.limitsStackPanelContainer = (Grid) target;
        break;
      case 14:
        this.panelLimitsRow = (RowDefinition) target;
        break;
      case 15:
        this.translationLimitsColumn = (ColumnDefinition) target;
        break;
      case 16 /*0x10*/:
        this.rotationLimitsColumn = (ColumnDefinition) target;
        break;
      case 17:
        this.stackPanelTranslation = (StackPanel) target;
        break;
      case 18:
        this.createTranslationLimits = (Grid) target;
        break;
      case 19:
        this.iconTranslationLock = (Image) target;
        break;
      case 20:
        this.labelTranslationMinValue = (TextBlock) target;
        break;
      case 21:
        this.labelTranslationMaxValue = (TextBlock) target;
        break;
      case 22:
        this.labelTranslationMinValueHidden = (TextBlock) target;
        break;
      case 23:
        this.labelTranslationMaxValueHidden = (TextBlock) target;
        break;
      case 24:
        this.cbLimitsTx = (CheckBox) target;
        break;
      case 25:
        this.cbLockedTx = (CheckBox) target;
        break;
      case 26:
        this.TxNumericEditTxMin = (TxNumericEditBoxControl) target;
        ((FrameworkElement) this.TxNumericEditTxMin).SizeChanged += new SizeChangedEventHandler(this.OnMinTranslationEditorSizeChanged);
        break;
      case 27:
        this.TxNumericEditTxMax = (TxNumericEditBoxControl) target;
        ((FrameworkElement) this.TxNumericEditTxMax).SizeChanged += new SizeChangedEventHandler(this.OnMaxTranslationEditorSizeChanged);
        break;
      case 28:
        this.cbLimitsTy = (CheckBox) target;
        break;
      case 29:
        this.cbLockedTy = (CheckBox) target;
        break;
      case 30:
        this.TxNumericEditTyMin = (TxNumericEditBoxControl) target;
        ((FrameworkElement) this.TxNumericEditTyMin).SizeChanged += new SizeChangedEventHandler(this.OnMinTranslationEditorSizeChanged);
        break;
      case 31 /*0x1F*/:
        this.TxNumericEditTyMax = (TxNumericEditBoxControl) target;
        ((FrameworkElement) this.TxNumericEditTyMax).SizeChanged += new SizeChangedEventHandler(this.OnMaxTranslationEditorSizeChanged);
        break;
      case 32 /*0x20*/:
        this.cbLimitsTz = (CheckBox) target;
        break;
      case 33:
        this.cbLockedTz = (CheckBox) target;
        break;
      case 34:
        this.TxNumericEditTzMin = (TxNumericEditBoxControl) target;
        ((FrameworkElement) this.TxNumericEditTzMin).SizeChanged += new SizeChangedEventHandler(this.OnMinTranslationEditorSizeChanged);
        break;
      case 35:
        this.TxNumericEditTzMax = (TxNumericEditBoxControl) target;
        ((FrameworkElement) this.TxNumericEditTzMax).SizeChanged += new SizeChangedEventHandler(this.OnMaxTranslationEditorSizeChanged);
        break;
      case 36:
        this.showGraphicLimitsGrid = (Grid) target;
        break;
      case 37:
        this.cbShowInViewer = (CheckBox) target;
        break;
      case 38:
        this.stackPanelRotation = (StackPanel) target;
        break;
      case 39:
        this.createRotationLimits = (Grid) target;
        break;
      case 40:
        this.iconRotationLock = (Image) target;
        break;
      case 41:
        this.labelRotationMinValue = (TextBlock) target;
        break;
      case 42:
        this.labelRotationMaxValue = (TextBlock) target;
        break;
      case 43:
        this.labelRotationMinValueHidden = (TextBlock) target;
        break;
      case 44:
        this.labelRotationMaxValueHidden = (TextBlock) target;
        break;
      case 45:
        this.cbLimitsRx = (CheckBox) target;
        break;
      case 46:
        this.cbLockedRx = (CheckBox) target;
        break;
      case 47:
        this.TxNumericEditRxMin = (TxNumericEditBoxControl) target;
        this.TxNumericEditRxMin.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditRxMin_TentativeValueChanged);
        ((FrameworkElement) this.TxNumericEditRxMin).SizeChanged += new SizeChangedEventHandler(this.OnMinRotationEditorSizeChanged);
        break;
      case 48 /*0x30*/:
        this.TxNumericEditRxMax = (TxNumericEditBoxControl) target;
        this.TxNumericEditRxMax.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditRxMax_TentativeValueChanged);
        ((FrameworkElement) this.TxNumericEditRxMax).SizeChanged += new SizeChangedEventHandler(this.OnMaxRotationEditorSizeChanged);
        break;
      case 49:
        this.cbLimitsRy = (CheckBox) target;
        break;
      case 50:
        this.cbLockedRy = (CheckBox) target;
        break;
      case 51:
        this.TxNumericEditRyMin = (TxNumericEditBoxControl) target;
        this.TxNumericEditRyMin.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditRyMin_TentativeValueChanged);
        ((FrameworkElement) this.TxNumericEditRyMin).SizeChanged += new SizeChangedEventHandler(this.OnMinRotationEditorSizeChanged);
        break;
      case 52:
        this.TxNumericEditRyMax = (TxNumericEditBoxControl) target;
        this.TxNumericEditRyMax.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditRyMax_TentativeValueChanged);
        ((FrameworkElement) this.TxNumericEditRyMax).SizeChanged += new SizeChangedEventHandler(this.OnMaxRotationEditorSizeChanged);
        break;
      case 53:
        this.cbLimitsRz = (CheckBox) target;
        break;
      case 54:
        this.cbLockedRz = (CheckBox) target;
        break;
      case 55:
        this.TxNumericEditRzMin = (TxNumericEditBoxControl) target;
        this.TxNumericEditRzMin.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditRzMin_TentativeValueChanged);
        ((FrameworkElement) this.TxNumericEditRzMin).SizeChanged += new SizeChangedEventHandler(this.OnMinRotationEditorSizeChanged);
        break;
      case 56:
        this.TxNumericEditRzMax = (TxNumericEditBoxControl) target;
        this.TxNumericEditRzMax.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.TxNumericEditRzMax_TentativeValueChanged);
        ((FrameworkElement) this.TxNumericEditRzMax).SizeChanged += new SizeChangedEventHandler(this.OnMaxRotationEditorSizeChanged);
        break;
      case 57:
        this.simulateRotationLimits = (Grid) target;
        break;
      case 58:
        this.labelPreviewSimulate = (TextBlock) target;
        break;
      case 59:
        this.btPreviewRx = (Button) target;
        this.btPreviewRx.Click += new RoutedEventHandler(this.btPreviewRx_Click);
        break;
      case 60:
        this.btPreviewRy = (Button) target;
        this.btPreviewRy.Click += new RoutedEventHandler(this.btPreviewRy_Click);
        break;
      case 61:
        this.btPreviewRz = (Button) target;
        this.btPreviewRz.Click += new RoutedEventHandler(this.btPreviewRz_Click);
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
